<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>收藏夹</title>
</head>
<body>
<div id="collect">
    <table border="1" cellspacing="0">
        <thead>
        <tr align="center" height="40">
            <th width="300">标题</th>
            <th width="850">简介</th>
            <th width="50">点赞</th>
            <th width="90">发布日期</th>
            <th width="100">作者</th>
        </tr>
        </thead>
        <tr v-for="blog in blogs" aligen="center" height="40">
            <td>{{blog.title}}</td>
            <td>{{blog.description}}</td>
            <td>{{blog.praise}}</td>
            <td>{{blog.date}}</td>
            <td>{{blog.username}}</td>
            <td>
                <form action="./browse.html" method="get">
                    <input style="display: none" type="text" name="blogId" :value="blog.id">
                    <input type="submit" value="查看" >
                </form>
            </td>
        </tr>
    </table>
</div>
</body>
</html>

<script src="../js/ajax.js"></script>
<script src="../js/vue.js"></script>

<script>

    window.onload=function getblog() {
        let user_name=localStorage.getItem("loginName");
        new Vue({
            el:"#collect",
            data(){
                return{
                    blogs:[]
                }
            },
            mounted(){
                let _this=this;
                ajax({
                    method: "post",
                    url: "../../collect",
                    data: {
                        userName:user_name,
                        code:0
                    },
                    success: function (result) {
                        console.log(result);
                        _this.blogs=result;
                    },
                    error:function (result){
                        console.log(result);
                    }
                })
            }
        })
    }
</script>